<html>
<head>
<title>Login</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/bootstrap-theme.min.css" >
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>public/css/style.css">
	<script type="text/javascript" src="<?php echo base_url(); ?>public/js/jquery.min.js"></script>
	<script type="text/javascript" src="<?php echo base_url();?>public/js/bootstrap.min.js"></script>
</head>
</head>
<body >	
	<?php 
		$p="article";
	?>	
	<?php
		$this->load->view("admin/head")
	?>
	<div class="modal fade">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
	        <h4 class="modal-title">Modal title</h4>
	      </div>
	      <div class="modal-body">
	        <p>One fine body&hellip;</p>
	      </div>
	      <div class="modal-footer">
	        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
	        <button type="button" class="btn btn-primary">Save changes</button>
	      </div>
	    </div><!-- /.modal-content -->
	  </div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<div class="container" >
			<h1 >文章列表
			<a href="<?php echo site_url('/admin/article/add') ?>"><button type="button" class="btn btn-success pull-right">添加</button></a>
			</h1>	
		<table class="table table-bordered table-condensed" >
		<tr>
			<th>标题</th>
			<th>创建时间</th>
			<th>访问人数</th>
			<th>是否推荐</th>
			<th>操作</th>
		</tr>
		<tr>		
			<?php
				if(empty($articles)){
					?>
			<td colspan="9" class="empty">
					没有数据
			</td>
			<?php
				}
			?>
		</tr>
			<?php
				foreach ($articles as $a) {
			?>
		<tr>
			<td><a class="title" href="<?php echo site_url('Article/view/'.$a->id);?>"><?php echo $a->title;?></a></td>
			<td><?php echo date("Y-m-d H:i:s",$a->create_time); ?></td>
			<td><?php echo $a->view; ?></td>
			<td>
			<?php echo  $a->recommend==1?"<button type=\"button\" class=\"btn btn-success\">已推荐</button>":""; ?></td>
			<td>
				<a href="<?php echo site_url('admin/article/recommend/'.$a->id);?>" class="recommend">

				<?php echo  $a->recommend==1?"<button type=\"button\" class=\"btn btn-primary\">取消推荐</button>":"<button type=\"button\" class=\"btn btn-primary\">推荐</button>"; ?></a>&nbsp;&nbsp;
				<a href="<?php echo site_url('admin/Article/edit/'.$a->id);?>"><button type="button" class="btn btn-warning btn-sm edit">修改</button></a>&nbsp;&nbsp;
				<a class="del" href="<?php echo site_url('/admin/article/delete/'.$a->id) ;?>">
				<button  type="button" class="btn btn-danger btn-sm  del" >删除</button></a>
			</td>
		</tr>
			<?php
				}
			?>			
	</table>
	<?php echo $this->pagination->create_links();?>
	</div>
	<script type="text/javascript">
		$(function(){
			$('.recommend').click(function(){
				var href=$(this).attr('href');
				$.get(href,function(data,status){
					location.reload(); 
				});
				return false;
			});
			$('.del').click(function(){
				if(confirm('是否删除？')){
				var href=$(this).attr('href');
				$.get(href,function(data,status){
					location.reload(); 
				});
			}
				return false;
			});
			$('.edit').click(function(){
				var href=$(this).attr('href');
				$.get(href,function(data,status){
					
					location.reload(); 
				});
				return false;
		});
	</script>
</body>
</html>